From: Keir Fraser Date: Fri, 11 Jul 2008 11:49:14 +0000 (+0100) Subject: iommu: make interrupt remapping more generic X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14188^2~41 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=04e28c8d4f8411cb8af638124676142edfcda1b5;p=xen.git iommu: make interrupt remapping more generic Signed-off-by: Wei Wang --- diff --git a/xen/arch/x86/msi.c b/xen/arch/x86/msi.c index d99dc4aacb..c0ccba6d9a 100644 --- a/xen/arch/x86/msi.c +++ b/xen/arch/x86/msi.c @@ -173,8 +173,8 @@ static int unset_vector_msi(int vector) static void write_msi_msg(struct msi_desc *entry, struct msi_msg *msg) { - if ( vtd_enabled ) - msi_msg_write_remap_rte(entry, msg); + if ( iommu_enabled ) + iommu_update_ire_from_msi(entry, msg); switch ( entry->msi_attrib.type ) { diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/passthrough/amd/pci_amd_iommu.c index bc3f474850..31f485086c 100644 --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c @@ -649,4 +649,6 @@ struct iommu_ops amd_iommu_ops = { .unmap_page = amd_iommu_unmap_page, .reassign_device = amd_iommu_return_device, .get_device_group_id = amd_iommu_group_id, + .update_ire_from_apic = amd_iommu_ioapic_update_ire, + .update_ire_from_msi = amd_iommu_msi_msg_update_ire, }; diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index 26719e4b58..5d41ddfb87 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -290,6 +290,43 @@ int iommu_get_device_group(struct domain *d, u8 bus, u8 devfn, return i; } + +void iommu_update_ire_from_apic( + unsigned int apic, unsigned int reg, unsigned int value) +{ + struct iommu_ops *ops = NULL; + + switch ( boot_cpu_data.x86_vendor ) + { + case X86_VENDOR_INTEL: + ops = &intel_iommu_ops; + break; + case X86_VENDOR_AMD: + ops = &amd_iommu_ops; + break; + default: + BUG(); + } + ops->update_ire_from_apic(apic, reg, value); +} +void iommu_update_ire_from_msi( + struct msi_desc *msi_desc, struct msi_msg *msg) +{ + struct iommu_ops *ops = NULL; + + switch ( boot_cpu_data.x86_vendor ) + { + case X86_VENDOR_INTEL: + ops = &intel_iommu_ops; + break; + case X86_VENDOR_AMD: + ops = &amd_iommu_ops; + break; + default: + BUG(); + } + ops->update_ire_from_msi(msi_desc, msg); +} /* * Local variables: * mode: C diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index c5b76b21c3..67126140a1 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1883,6 +1883,8 @@ struct iommu_ops intel_iommu_ops = { .unmap_page = intel_iommu_unmap_page, .reassign_device = reassign_device_ownership, .get_device_group_id = intel_iommu_group_id, + .update_ire_from_apic = io_apic_write_remap_rte, + .update_ire_from_msi = msi_msg_write_remap_rte, }; /* diff --git a/xen/include/asm-x86/io_apic.h b/xen/include/asm-x86/io_apic.h index 00fafcf55d..72b6defb97 100644 --- a/xen/include/asm-x86/io_apic.h +++ b/xen/include/asm-x86/io_apic.h @@ -133,8 +133,8 @@ static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg) static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value) { - if (vtd_enabled) - return io_apic_write_remap_rte(apic, reg, value); + if (iommu_enabled) + return iommu_update_ire_from_apic(apic, reg, value); *IO_APIC_BASE(apic) = reg; *(IO_APIC_BASE(apic)+4) = value; } diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 390fb9e4d1..20ba06062c 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -103,6 +103,10 @@ struct iommu_ops { int (*reassign_device)(struct domain *s, struct domain *t, u8 bus, u8 devfn); int (*get_device_group_id)(u8 bus, u8 devfn); + void (*update_ire_from_apic)(unsigned int apic, unsigned int reg, unsigned int value); + void (*update_ire_from_msi)(struct msi_desc *msi_desc, struct msi_msg *msg); }; +void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, unsigned int value); +void iommu_update_ire_from_msi(struct msi_desc *msi_desc, struct msi_msg *msg); #endif /* _IOMMU_H_ */